var a = getApp();

Page({
    data: {
        language: "",
        page: 1
    },
    onLoad: function(a) {
        this.getData(), this.getList();
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.current_page >= this.data.last_page) wx.showToast({
            title: "暂无更多",
            icon: "none",
            duration: 1e3
        }); else {
            var a = this.data.page + 1;
            this.setData({
                page: a
            }), this.getNext();
        }
    },
    onShareAppMessage: function() {},
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.weighted_dividend.api.index.weightedData");
        a._postNetWork({
            url: e,
            data: {
                art: "index"
            },
            success: function(a) {
                var e = a.data;
                1 == e.result && (console.log(e.data.index), t.setData({
                    info: e.data.index
                }), wx.setNavigationBarTitle({
                    title: e.data.index.weighted_name
                }));
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getList: function() {
        var t = this, e = a.getNetAddresss("plugin.weighted_dividend.api.index.weightedData");
        a._postNetWork({
            url: e,
            data: {
                art: "getData",
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                1 == e.result && (console.log(e.data), t.setData({
                    current_page: e.data.getData.data.current_page,
                    last_page: e.data.getData.data.last_page,
                    list: e.data.getData.data.data
                }));
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getNext: function() {
        var t = this, e = a.getNetAddresss("plugin.weighted_dividend.api.index.weightedData");
        a._postNetWork({
            url: e,
            data: {
                art: "getData",
                page: t.data.page
            },
            success: function(a) {
                var e = a.data;
                1 == e.result && (console.log(e.data), t.setData({
                    current_page: e.data.getData.data.current_page,
                    last_page: e.data.getData.data.last_page,
                    list: t.data.list.concat(e.data.getData.data.data)
                }));
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    goAchievement: function(a) {
        var t = a.currentTarget.dataset.type;
        wx.navigateTo({
            url: "/packageD/dividendsAchievement/dividendsAchievement?type=" + t
        });
    }
});